/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  return Object.keys(str).length > 0;
}

/**
 * 效验密码
 * @param {*} value 
 * @param {*} callback 
 */
export function confirmPassword(value, callback, formData) {
  if (value === '') {
    callback(new Error("请再次输入密码"));
  } else if (value !== formData.userPassword) {
    callback(new Error("两次输入密码不一致!"));
  } else {
    callback();
  }
}
